﻿<%@ Page Title="Goods Receipt" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true"
    CodeBehind="GoodsReceipt.aspx.cs" Inherits="VSM.GoodsReceipt" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script type="text/javascript">
        function isNumberKey(sender, evt) {
            var txt = sender.value;
            var dotcontainer = txt.split('.');
            var charCode = (evt.which) ? evt.which : event.keyCode;
            if (!(dotcontainer.length == 1 && charCode == 46) && charCode > 31 && (charCode < 48 || charCode > 57)) return false;
            return true;
        }

        function OpenItemPopup() {
            var url = "../../ItemPopup.aspx?itmgrp=104"
            Main.openCustomDialog(url, 600, 610, "Item Master Data");
        }

        function OpenBP() {
            var url = "../../BPPopup.aspx?CardType=S";
            Main.openCustomDialog(url, 600, 610, "Business Partner List");
        }

        function OpenDocList(docktype, title) {
            var url = "../../DocumentList.aspx?DocType=" + docktype
            Main.openCustomDialog(url, 800, 610, title);
        }
    </script>
    <div>
        <asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:HiddenField ID="hdnIsUpdate" runat="server" />
                <asp:HiddenField ID="hdnStatus" runat="server" />
                <h2>
                    &nbsp;<asp:Label ID="lblTitle" runat="server" Text="Goods Receipt"></asp:Label>
                </h2>
                <div style="margin-left: 5px; width: 99%;">
                    <hr />
                    <table border="0" width="100%" style="background-color: #D1D4D8; font-weight: bold;">
                        <tr>
                            <td style="border-bottom: dotted 1px #808080; vertical-align: bottom;">Document No.:</td>
                            <td>
                                <asp:TextBox ID="txtDocNo" runat="server" BackColor="#E6E6E6" ReadOnly="True" 
                                    Width="122px"></asp:TextBox>
                            </td>
                            <td style="border-bottom: dotted 1px #808080; vertical-align: bottom; width: 100px;">
                                Doc. Date:</td>
                            <td align="left">
                                <asp:TextBox ID="txtDocDate" runat="server"></asp:TextBox>
                                <cc1:CalendarExtender ID="CalendarExtender1" runat="server" Format="dd/MM/yyyy" 
                                    PopupButtonID="imgDocDate" TargetControlID="txtDocDate">
                                </cc1:CalendarExtender>
                                <asp:ImageButton ID="imgDocDate" runat="Server" AlternateText="Click to show calendar" 
                                    ImageUrl="~/Images/Calendar_scheduleHS.png" />
                                <asp:Label ID="lblDocDateRequired" runat="server" ForeColor="Red" Text="*"></asp:Label>
                            </td>
                            <td align="right" >
                                <asp:Button ID="btnDocList" runat="server" OnClientClick="OpenDocList('59', 'Goods Receipt List'); return false;" 
                                    Style="background-image: url('/Images/bgButton.png'); background-repeat: no-repeat;" Text="List" Width="60px" />
                            </td>
                        </tr>
                        <tr>
                            <td style="border-bottom: dotted 1px #808080; vertical-align: bottom; width: 150px;">Posting Date:</td>
                            <td style="width: 250px;" colspan="4">
                                <asp:TextBox ID="txtPostingDate" runat="server"></asp:TextBox>
                                <cc1:CalendarExtender ID="txtPostingDate_CalendarExtender" runat="server" 
                                    Format="dd/MM/yyyy" PopupButtonID="imgPostingDate" TargetControlID="txtPostingDate">
                                </cc1:CalendarExtender>
                                <asp:ImageButton ID="imgPostingDate" runat="Server" AlternateText="Click to show calendar" ImageUrl="~/Images/Calendar_scheduleHS.png" />
                                <asp:Label ID="lblPosDateRequired" runat="server" ForeColor="Red" Text="*"></asp:Label>
                            </td>
                        </tr>
                    </table>
                    <table id="Table1" width="100%" style="font-weight: bold">
                        <tr>
                            <td class="FormLineItemAlt" valign="middle" colspan="4">
                                <asp:Button ID="btnAddItems" runat="server" Text="Add vehicle"
                                    Style="background-image: url('/Images/bgButton.png'); background-repeat: no-repeat;" 
                                    Width="85px" onclick="btnAddItems_Click" />
                                <asp:Button ID="btnAddAccessories" runat="server" OnClientClick="OpenItemPopup();return false;" 
                                    
                                    Style="background-image: url('/Images/bgButton.png'); background-repeat: no-repeat;" 
                                    Text="Add accessories" Width="110px" />
                                <asp:Button ID="btnGetTemplate" runat="server" onclick="btnGetTemplate_Click" 
                                    Style="background-image: url('/Images/bgButton.png'); background-repeat: no-repeat;" 
                                    text="Get Template" Width="90px" />
                                <asp:FileUpload ID="FileUploadControl" runat="server" />
                                <asp:Button ID="btnImport" runat="server" onclick="btnImport_Click" 
                                    Style="background-image: url('/Images/bgButton.png'); background-repeat: no-repeat;" 
                                    text="Import" Width="60px" />
                            </td>
                        </tr>
                    </table>
                    <hr />
                    <div style="width: 100%">
                        <asp:GridView ID="grvGRPT" CssClass="GridInner" runat="server" Width="100%" BorderColor="White"
                            BackColor="White" AllowSorting="True" AutoGenerateColumns="False" CellPadding="2"
                            HeaderStyle-Height="27px" OnRowCreated="grvGRPO_RowCreated" 
                            CellSpacing="2" HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center"
                            AllowPaging="True" OnPageIndexChanging="grvSearchResult_PageIndexChanging" 
                            PageSize="20" OnRowDataBound="grvSearchResult_RowDataBound">
                            <PagerSettings Mode="NumericFirstLast" />
                            <PagerStyle BackColor="#70A0D0" Font-Bold="True" HorizontalAlign="Center" VerticalAlign="Middle" />
                            <RowStyle BackColor="#D9E0ED" BorderColor="White" BorderWidth="2px" Height="25px" />
                            <AlternatingRowStyle BackColor="#EEF1F7" BorderColor="White" BorderWidth="2px" />
                            <Columns>
                                <asp:CommandField HeaderText="Action" ShowDeleteButton="True" ShowEditButton="False"
                                    Visible="false" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
                                    ItemStyle-Width="70px" />
                                <asp:TemplateField HeaderText="Action">
                                    <ItemStyle HorizontalAlign="Center" Width="20px" />
                                    <HeaderStyle VerticalAlign="Middle" />
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lnkDelete" runat="server" Text="Delete" TabIndex="-1" OnClick="lnkDelete_Click"></asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="#">
                                    <ItemStyle HorizontalAlign="Center" Width="20px" />
                                    <HeaderStyle VerticalAlign="Middle" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblNo" runat="server" Text='<%# Bind("No") %>' BorderStyle="none">
                                        </asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Item Code" Visible="false">
                                    <ItemStyle HorizontalAlign="Center" />
                                    <HeaderStyle VerticalAlign="Middle" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblItemCode" runat="server" Text='<%# Bind("ItemCode") %>' ></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Model">
                                    <ItemStyle HorizontalAlign="Center" Width="120px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:DropDownList ID="ddlModel" AutoPostBack="true" onselectedindexchanged="ddlModel_SelectedIndexChanged" style="width: 98%;" runat="server">
                                        </asp:DropDownList>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Product">
                                    <ItemStyle HorizontalAlign="Center" Width="120px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:DropDownList ID="ddlProduct" AutoPostBack="true" onselectedindexchanged="ddlProduct_SelectedIndexChanged" style="width: 98%;" runat="server">
                                        </asp:DropDownList>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Color">
                                    <ItemStyle HorizontalAlign="Center" Width="200px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:DropDownList ID="ddlColor" AutoPostBack="true" onselectedindexchanged="ddlColor_SelectedIndexChanged" style="width: 98%;" runat="server">
                                        </asp:DropDownList>
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Item Name">
                                    <ItemStyle HorizontalAlign="left" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <HeaderTemplate>
                                        <asp:label ID="lblHeaderItemName" runat="Server" Text="Item Name" />
                                        <asp:label ID="lblItemNameRequired" runat="server" Font-Bold="true" Text="*" ForeColor="Red" />
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="lblItemName" runat="server" Text='<%# Bind("Dscription") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Model" Visible="false">
                                    <HeaderStyle VerticalAlign="Middle" />
                                    <ItemStyle HorizontalAlign="Center" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblModel" runat="server" Text='<%# Bind("U_Model") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Product" Visible="false">
                                    <HeaderStyle VerticalAlign="Middle" />
                                    <ItemStyle HorizontalAlign="Center" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblProduct" runat="server" Text='<%# Bind("U_Product") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Color" Visible="false">
                                    <HeaderStyle VerticalAlign="Middle" />
                                    <ItemStyle HorizontalAlign="Center" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblColor" runat="server" Text='<%# Bind("U_Color") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Warehouse">
                                    <ItemStyle HorizontalAlign="Center" Width="130px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:DropDownList ID="ddlWhs" AutoPostBack="true" OnSelectedIndexChanged="ddlWhs_SelectedIndexChanged" Style="width: 98%;" runat="server" />
                                        <asp:HiddenField ID="hdnWhsCode" Value='<%# Bind("WhsCode") %>' runat="server" />
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Order Qty.">
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle VerticalAlign="Middle" Width="80px" />
                                    <ItemTemplate>
                                        <asp:TextBox ID="txtOrderQuantity" Style="text-align: right"  runat="server" Width="97%" Text='<%# Bind("Quantity")%>'
                                            AutoPostBack="true" OnKeyPress="return isNumberKey(this, event);" OnTextChanged="txtOrderQuantity_OnTextChanged"/>
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="is Goods Issue">
                                    <ItemStyle HorizontalAlign="Center" />
                                    <HeaderStyle VerticalAlign="Middle" Width="80px" />
                                    <ItemTemplate>
                                        <asp:CheckBox ID="chkIsGoodsIssue" Style="text-align: center"  runat="server" Width="97%" Checked="false" AutoPostBack="true" />
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <%--<asp:TemplateField HeaderText="VIN Number" Visible="false">
                                    <ItemStyle HorizontalAlign="Left" />
                                    <HeaderStyle VerticalAlign="Middle" Width="150px" />
                                    <ItemTemplate>
                                        <asp:TextBox ID="txtDistNumber" runat="server" Width="97%" Text='<%# Bind("DistNumber") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>--%>

                                <%--<asp:TemplateField HeaderText="Engine Number" Visible="false">
                                    <ItemStyle HorizontalAlign="Left" />
                                    <HeaderStyle VerticalAlign="Middle" Width="100px" />
                                    <ItemTemplate>
                                        <asp:TextBox ID="txtEngineNumber" runat="server" Width="97%" Text='<%# Bind("Notes") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>--%>

 <%--                               <asp:TemplateField HeaderText="Unit Price">
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle VerticalAlign="Middle" Width="100px" />
                                    <ItemTemplate>
                                        <asp:TextBox ID="txtUnitPrice" Style="text-align: right" Width="97%" runat="server" Text='<%# Bind("PriceBefDi") %>' 
                                            AutoPostBack="true" OnKeyPress="return isNumberKey(this, event);" OnTextChanged="txtUnitPrice_OnTextChanged"/>
                                    </ItemTemplate>
                                </asp:TemplateField>--%>

<%--                                <asp:TemplateField HeaderText="Disc. (%)">
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle VerticalAlign="Middle" Width="80px" />
                                    <ItemTemplate>
                                        <asp:TextBox ID="txtDiscPrcnt" Style="text-align: right" Width="97%" runat="server" Text='<%# Bind("DiscPrcnt") %>' 
                                            AutoPostBack="true" OnKeyPress="return isNumberKey(this, event);" OnTextChanged="txtDiscPrcnt_OnTextChanged"/>
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Price After Disc" Visible="false">
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle VerticalAlign="Middle" Width="100px" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblPrice" Style="text-align: right" runat="server" Text='<%# Bind("Price") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Line Total">
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle VerticalAlign="Middle" Width="120px" />
                                    <ItemTemplate>
                                        <asp:Label ID="txtLineTotal" runat="server" Text='<%# Bind("LineTotal") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>--%>
                            </Columns>
                            <HeaderStyle BackColor="#6095C9" Font-Bold="true" ForeColor="#ffffff" Font-Overline="False"
                                Height="27px" VerticalAlign="Bottom" />
                            <EmptyDataTemplate>
                                <table class="GridInner" style="width: 100%; border-color: White;" border="1" rules="all" cellspacing="2" cellpadding="2">
                                    <tr valign="middle" style="height: 27px; color: white; font-weight: bold; text-decoration: none; background-color: rgb(96, 149, 201);">
                                        <th>
                                            <span>Action</span>
                                        </th>
                                        <th>
                                            <span>#</span>
                                        </th>
                                        <th>
                                            <span>Model</span>
                                        </th>
                                        <th>
                                            <span>Product</span>
                                        </th>
                                        <th>
                                            <span>Color</span>
                                        </th>
                                        <th>
                                            <span>Item Name</span>
                                        </th>
                                        <th>
                                            <span>Warehouse</span>
                                        </th>
                                        <th>
                                            <span>Order Qty.</span>
                                        </th>
                                        <th>
                                            <span>is Goods Issue</span>
                                        </th>                                        
                                    </tr>
                                    <tr>
                                        <td colspan="10">
                                            <span>No Data</span>
                                        </td>
                                    </tr>
                                </table>
                            </EmptyDataTemplate>
                        </asp:GridView>
                    </div>
                    <hr width="100%" />
                </div>
                <table width="100%" border="0">
                    <tr>
                        <td valign="top" style="width: 70%;">
                            <table style="width: 100%;">
                                <tr>
                                    <td style="width: 10%;">
                                        <strong>Remarks:</strong>
                                    </td>
                                    <td style="width: 40%;">
                                        <asp:TextBox runat="server" ID="txtRemarks" Height="71px" style="width: 98%;" TextMode="MultiLine" ></asp:TextBox>
                                    </td>
                                    <td style="width: 50%;"></td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <div style="margin-left: 5px; width: 99%;">
                                <hr />
                            </div>
                            <table style="width: 100%">
                                <tr>
                                    <td style="width: 250px;">
                                        <asp:Button ID="btnSave" runat="server" Text="Save" Style="background-image: url('/Images/bgButton.png');
                                            background-repeat: no-repeat; color: White;" OnClick="btnSave_Click"   OnClientClick="return confirm('Are you sure? After saved, you cannot edit anythings in this Goods Receipt.');"
                                            BorderStyle="Solid" Width="60px" />
                                        <asp:Button ID="btnCancel" runat="server" Text="Cancel" Style="background-image: url('/Images/bgButton.png'); background-repeat: no-repeat; color: White;" 
                                            OnClientClick="return confirm('Are you sure? After Canced, you cannot edit anythings in this Goods Receipt.');"
                                            OnClick="btnCancel_Click" BorderStyle="Solid" Width="60px" />
                                        <asp:Button ID="btnPrint" runat="server" BorderStyle="Solid" 
                                            Style="background-image: url('/Images/bgButton.png'); background-repeat: no-repeat; color: White;" 
                                            Text="Print" Width="60px" />
                                        <asp:Button ID="btnLastRecord" runat="server" BorderStyle="Solid" 
                                            OnClick="btnLastRecord_Click" 
                                            Style="background-image: url('/Images/bgButton.png'); background-repeat: no-repeat; color: White;" 
                                            Text="&gt;&gt;" Width="40px" />
                                    </td>
                                    <td colspan="2">
                                        <asp:Label ID="lblError" runat="server" Visible="False" Font-Bold="True" ForeColor="Red"></asp:Label>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="3"></td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
            <Triggers>
                <asp:PostBackTrigger  ControlID="btnImport" />
                 <asp:PostBackTrigger  ControlID="btnGetTemplate" />
            </Triggers>
        </asp:UpdatePanel>
    </div>
</asp:Content>
